//
//  RWRemindListView.m
//  Chat
//
//  Created by 任伟 on 16/3/8.
//  Copyright © 2016年 任伟. All rights reserved.
//

#define relovate(forgX) (ScreenWidth/320)*forgX

#import "RWRemindListView.h"

@implementation RWRemindListView

/// 创建头部的6个按钮
- (void)initSubView {

    [self addSubview:[self creatBtnWithTitle:@"商务提醒" Image:[UIImage imageNamed:@"icon_sw"] Frame:CGRectMake(ScreenWidth/2 - relovate(25), 10, relovate(100), relovate(100)) Tag:eBusinessType Action:@selector(buttonAction:)]];
    [self addSubview:[self creatBtnWithTitle:@"缴费提醒" Image:[UIImage imageNamed:@"icon_jf"] Frame:CGRectMake(self.width - relovate(85), self.height/2 - relovate(40), relovate(80), relovate(80)) Tag:ePaymentType Action:@selector(buttonAction:)]];
    [self addSubview:[self creatBtnWithTitle:@"祝福语" Image:[UIImage imageNamed:@"icon_zfy"] Frame:CGRectMake(self.width - relovate(130), self.height - relovate(90), relovate(90), relovate(90)) Tag:eBlessingType Action:@selector(buttonAction:)]];
    [self addSubview:[self creatBtnWithTitle:@"倒计时" Image:[UIImage imageNamed:@"icon_djs"] Frame:CGRectMake(self.width/2 - relovate(65), self.height - relovate(60), relovate(80), relovate(80)) Tag:eCountdownType Action:@selector(buttonAction:)]];
    [self addSubview:[self creatBtnWithTitle:@"自定义" Image:[UIImage imageNamed:@"icon_zdy"] Frame:CGRectMake(relovate(0), self.height - relovate(130), relovate(90), relovate(90)) Tag:eCustomType Action:@selector(buttonAction:)]];
    [self addSubview:[self creatBtnWithTitle:@"重要日子" Image:[UIImage imageNamed:@"icon_zy"] Frame:CGRectMake(relovate(20), self.width/2 - relovate(100), relovate(70), relovate(70)) Tag:eImportantType Action:@selector(buttonAction:)]];
    
    NSLog(@"%f",relovate(15));

}

/// 隐藏标题文字
- (void)hideTitle
{
    [[self viewWithTag:eBusinessType] viewWithTag:1002].hidden = YES;
    [[self viewWithTag:ePaymentType] viewWithTag:1002].hidden = YES;
    [[self viewWithTag:eBlessingType] viewWithTag:1002].hidden = YES;
    [[self viewWithTag:eCountdownType] viewWithTag:1002].hidden = YES;
    [[self viewWithTag:eCustomType] viewWithTag:1002].hidden = YES;
    [[self viewWithTag:eImportantType] viewWithTag:1002].hidden = YES;
}

/// 显示标题文字
- (void)showTitle
{
    [[self viewWithTag:eBusinessType] viewWithTag:1002].hidden = NO;
    [[self viewWithTag:ePaymentType] viewWithTag:1002].hidden = NO;
    [[self viewWithTag:eBlessingType] viewWithTag:1002].hidden = NO;
    [[self viewWithTag:eCountdownType] viewWithTag:1002].hidden = NO;
    [[self viewWithTag:eCustomType] viewWithTag:1002].hidden = NO;
    [[self viewWithTag:eImportantType] viewWithTag:1002].hidden = NO;
}


/// 自定义button
- (UIControl *)creatBtnWithTitle:(NSString *)title Image:(UIImage *)image Frame:(CGRect)frame Tag:(NSInteger)tag Action:(SEL)action
{
    UIControl *button=[[UIControl alloc]initWithFrame:frame];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width/5, 0, frame.size.width/5*3, frame.size.width/5*3)];
    [imageView setImage:image];
    imageView.tag = 1001;
    [button addSubview:imageView];
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, frame.size.width/5*3, frame.size.width, frame.size.width/5*2)];
    [titleLabel setFont:[UIFont systemFontOfSize:15]];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    [titleLabel setTextColor:RGBACOLOR(90, 90, 90, 1)];
    titleLabel.tag = 1002;
    [titleLabel setText:title];
    [button addSubview:titleLabel];
    button.tag = tag;
    [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
    return button;
}

/// button 的响应事件
- (IBAction)buttonAction:(UIControl *)sender
{
    UIImageView *image = [sender viewWithTag:1001];
    image.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
    [UIView animateWithDuration:0.3f animations:^{
        image.transform=CGAffineTransformMakeScale(1.2f, 1.2f);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.2f animations:^{
            image.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
        } completion:^(BOOL finished) {
            switch (sender.tag) {
                case eBusinessType:     //商务提醒
                {
//                    HEReminderCustomVC * customVC = [[HEReminderCustomVC alloc] initWithType:HEReminderCustomVCTypeBusiness];
//                    customVC.delegate = (HEReminderMainVC *)self.viewController;
//                    [self.viewController.navigationController pushViewController:customVC animated:YES];
                }
                    break;
                case ePaymentType:      //缴费提醒
                {
//                    HEReminderCustomVC * customVC = [[HEReminderCustomVC alloc] initWithType:HEReminderCustomVCTypePay];
//                    customVC.delegate = (HEReminderMainVC *)self.viewController;
//                    [self.viewController.navigationController pushViewController:customVC animated:YES];
                }
                    break;
                case eBlessingType:     //祝福语
                {
//                    HEBlessingsVC *blessings = [[HEBlessingsVC alloc]init];
//                    [self.viewController.navigationController pushViewController:blessings animated:YES];
                }
                    break;
                case eCountdownType:    //倒计时
                {
                    /// 做界面的跳转
//                    HEReminderCustomVC * countDownVC = [[HEReminderCustomVC alloc] initWithType:HEReminderCustomVCTypeCountDown];
//                    countDownVC.delegate = (HEReminderMainVC *)self.viewController;
//                    [self.viewController.navigationController pushViewController:countDownVC animated:YES];
                }
                    break;
                case eCustomType:       //自定义
                {
//                    HEReminderCustomVC * customVC = [[HEReminderCustomVC alloc] initWithType:HEReminderCustomVCTypeCustom];
//                    customVC.delegate = (HEReminderMainVC *)self.viewController;
//                    [self.viewController.navigationController pushViewController:customVC animated:YES];
                }
                    break;
                case eImportantType:    //重要日子
                {
//                    HEReminderCustomVC * customVC = [[HEReminderCustomVC alloc] initWithType:HEReminderCustomVCTypeImport];
//                    customVC.delegate = (HEReminderMainVC *)self.viewController;
//                    [self.viewController.navigationController pushViewController:customVC animated:YES];
                }
                    break;
                    
                default:
                    break;
            }
        }];
    }];
    
}


@end
